// TypeScript file
module Fighter {

    /**
     * 敌机防守——郭启航
     */
    export class EnemyDefenseUI extends eui.Component {

        constructor() {
            super();
            this.skinName = "resource/assets/PlaneE/EnemyDefenseUI.exml";
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.AddToStage, this);
        }
        public ShowTime: egret.Timer = new egret.Timer(1000);
        public EnemyHp: eui.ProgressBar = new eui.ProgressBar();
        public AddPrepareUI: eui.Group;
        public IS_AddPrepareUI: boolean;
        /**必杀动画*/
        public SlayAnimation: egret.MovieClip = new egret.MovieClip();
        public EnemyHome: eui.Image;
        /**播放特效*/
        public static PlayAnimation: boolean;
        public static EnemyHomeHp: number = 10;
        public static EnemyHomeAngle:number=0;
        public AddToStage() {
            this.EnemyHp.minimum = 0;
            this.EnemyHp.maximum = 10;
            this.EnemyHp.value = 10;
            this.EnemyHp.x = 250;
            this.EnemyHp.y = 950;
            this.EnemyHp.width = 160;
            //this.EnemyHp.height = 23;
            this.EnemyHp.skinName="resource/assets/FlyM/hpPlane_classics.exml";
            this.addChild(this.EnemyHp);
            this.IS_AddPrepareUI = false;
            this.AddPrepareUI.addEventListener(egret.TouchEvent.TOUCH_TAP, this.EnemyDreSwitchPre, this);
            this.ShowTime.addEventListener(egret.TimerEvent.TIMER, this.ShowTimeEven, this);
            this.ShowTime.start();
        }
        public EnemyDreSwitchPre() {
            this.IS_AddPrepareUI = true;
            //this.AddPrepareUI.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.EnemyDreSwitchPre,this);
        }
        /**每秒监听*/
        public ShowTimeEven() {
            this.EnemyHome.rotation=EnemyDefenseUI.EnemyHomeAngle*57.3;
            if (GameUtil.PlayerMessage.instance.onePerson) {
                this.EnemyHp.value = GameUtil.PlayerMessage.instance.enemyHomeHp
            }
            else {
                this.EnemyHp.value = EnemyDefenseUI.EnemyHomeHp;
            }

            this.PlayFrameAnimaTion();
        }
        /**播放动画*/
        public PlayFrameAnimaTion() {
            if (EnemyDefenseUI.PlayAnimation) {
                EnemyDefenseUI.PlayAnimation = false;
                var objPoint: egret.Point = new egret.Point(50, 100);
                this.SlayAnimation = FrameAnimation.instance.playAnimation(objPoint, "Slay");
                this.addChild(this.SlayAnimation);
                this.SlayAnimation.addEventListener(egret.Event.COMPLETE, this.RemoveAnimation, this);
            }
        }
        /**删除动画*/
        public RemoveAnimation() {
            this.removeChild(this.SlayAnimation);

        }
    }
}